/******************************************************************/
/*                                                                */
/*  Winpooch : Windows Watchdog                                   */
/*  Copyright (C) 2004-2005  Benoit Blanchon                      */
/*                                                                */
/*  This program is free software; you can redistribute it        */
/*  and/or modify it under the terms of the GNU General Public    */
/*  License as published by the Free Software Foundation; either  */
/*  version 2 of the License, or (at your option) any later       */
/*  version.                                                      */
/*                                                                */
/*  This program is distributed in the hope that it will be       */
/*  useful, but WITHOUT ANY WARRANTY; without even the implied    */
/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR       */
/*  PURPOSE.  See the GNU General Public License for more         */
/*  details.                                                      */
/*                                                                */
/*  You should have received a copy of the GNU General Public     */
/*  License along with this program; if not, write to the Free    */
/*  Software Foundation, Inc.,                                    */
/*  675 Mass Ave, Cambridge, MA 02139, USA.                       */
/*                                                                */
/******************************************************************/

#ifndef _SPYFUNCTIONS_H
#define _SPYFUNCTIONS_H

#include <wininet.h>

typedef enum {
  HOOKS_CREATEPROCESSA,
  HOOKS_CREATEPROCESSW,
  HOOKS_REGCREATEKEYEXA,
  HOOKS_REGCREATEKEYEXW,
  HOOKS_REGCLOSEKEYA,
  HOOKS_REGOPENKEYEXA,
  HOOKS_REGOPENKEYEXW,
  HOOKS_REGSETVALUEEXA,
  HOOKS_REGSETVALUEEXW,
  HOOKS_CREATEFILEW,
  HOOKS_DELETEFILEW,
  HOOKS_MOVEFILEWITHPROGRESSW, 
  HOOKS_CONNECT,
  HOOKS_LISTEN,
  _HOOKS_FUNCTION_COUNT
} HOOKS_FUNCTION ;

typedef enum {
  HOOKS_KERNEL32_DLL,
  HOOKS_ADVAPI32_DLL,
  HOOKS_WS2_32_DLL,
  _HOOKS_MODULE_COUNT
} HOOKS_MODULE ;

BOOL	Hooks_Init () ;

BOOL	Hooks_Uninit () ;
/*
LPCSTR	Hooks_GetProcName	(SPYFUNC id) ;

LPCTSTR	Hooks_GetDllName	(SPYFUNC id) ;

PROC	Hooks_GetProcAddress	(SPYFUNC id) ;

VOID	Hooks_SetStubAddress	(SPYFUNC id, PROC pfnStub) ;

PROC	Hooks_GetStubAddress	(SPYFUNC id) ;

BOOL	Hooks_IsEnabled		(SPYFUNC id) ;
*/

PROC	Hooks_GetStubAddress	(HOOKS_FUNCTION id) ;

LPVOID	Hooks_GetStubAddForJmp	(HOOKS_FUNCTION id) ;

BOOL	Hooks_InstallIntoFunction	(HOOKS_FUNCTION) ;

BOOL	Hooks_UninstallFromFunction	(HOOKS_FUNCTION) ;

BOOL	Hooks_DeleteFromFunction	(HOOKS_FUNCTION) ;


BOOL	Hooks_InstallIntoModule		(HOOKS_MODULE) ;

BOOL	Hooks_UninstallFromModule	(HOOKS_MODULE) ;

BOOL	Hooks_DeleteFromModule		(HOOKS_MODULE) ;


BOOL	Hooks_InstallIntoMappedModules	() ;

BOOL	Hooks_UninstallAll () ;


#define JUMP_TO_STUB(iFunc)				\
  asm (/*"int $3\n\t"*/					\
       "movl %%ebp, %%esp\n\t"				\
       "pop %%ebp\n\t"					\
       "jmp *(%%eax)"					\
       :: "a" (Hooks_GetStubAddForJmp(iFunc))) ;


#endif
